home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 5625 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: comma.rhein.de!serpens!not-for-mail
  2. From: mlelstv@serpens.rhein.de (Michael van Elst)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: My code crashes my computer
  5. Date: 17 Mar 1996 13:39:44 +0100
  6. Organization: dis-
  7. Message-ID: <4ih16g$dol@serpens.rhein.de>
  8. References: <4igm25$poj@goofy.BrandonU.CA>
  9. NNTP-Posting-Host: serpens.rhein.de
  10.  
  11. menon@beijing.brandonu.ca writes:
  12.  
  13. >void read_file(char *infile, char *infile2){
  14. >   int i=0, x, y, garb;
  15. >   FILE *fp;
  16. >   char *s="File Error";
  17. >   char *comment="", buf;
  18.  
  19. >   fp = fopen(infile, "r");
  20. >   if (fp==NULL){
  21. >         printf("FAILED!\n");
  22. >      perror(s);
  23. >         exit(1);
  24. >         }
  25. >   fgets(type,3,fp);
  26.  
  27. your compiler should complain about an error here.
  28.  
  29. >   fscanf(fp,"%s",comment);
  30. >   if (comment[0]=='#'){
  31. >     do{
  32. >        fscanf(fp, "%s",comment); 
  33. >          sprintf(buf,"%d",atoi(comment));  <---Crashes Here
  34.  
  35. obviously. sprintf awaits a pointer to a character array and not
  36. an uninitialized character variable. Your compile should complain
  37. here too.
  38.  
  39. >I compile it using:
  40. >gcc -o corr corr.c -m68040 -m68881
  41.  
  42. >If anyone can help me, I would greatly appreciate it.
  43.  
  44. Compile with -Wall to get some tons of warnings from your compiler.
  45.  
  46.  
  47. -- 
  48.                                 Michael van Elst
  49.  
  50. Internet: mlelstv@serpens.rhein.de
  51.                                 "A potential Snark may lurk in every tree."
  52.